package pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.interpolators.Interpolation;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.VisualObject;

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.5B2BA810-5114-881A-89D7-186415437A6C]
// </editor-fold>
/**
 * Default values for all paramters are Double.NaN, set only those you really wish to change,
 * all unchanged parameters will NOT be generated in javafx code and it will work just fine
 * @author Admin
 */
public class Shear implements Transformation ,java.io.Serializable{

    // Code block for changeListeners support start
    protected PropertyChangeSupport propertySupport= new PropertyChangeSupport(this);
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }
    // Code block for changeListeners support end

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.1CE3739D-5E91-EFF1-57CC-B77464432BF9]
    // </editor-fold> 
    public Shear () {
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.422BA16C-1232-B120-DFCE-848DA6009B32]
    // </editor-fold> 
    @Override
    public Interpolation getInterpolation () {
        return this.myInterpolations[0];
    }

    @Override
    public Interpolation[] getInterpolations() {
        return this.myInterpolations;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.F7BCEA75-ADA9-9733-ED82-F4E6E4941057]
    // </editor-fold> 
    @Override
    public void setInterpolation (Interpolation i) {
        Interpolation oldVal = this.myInterpolations[0];
        this.myInterpolations[0]=i;
        this.myInterpolations[1]=i;
        propertySupport.firePropertyChange( "Inerpolation" , oldVal, i);
    }


    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.A2C5EC94-A770-9FC2-634F-D6D9B8EB14B3]
    // </editor-fold> 
    @Override
    public VisualObject transform (double howMuch, VisualObject transformable,VisualObject orginalTransformedObject) {
        double shearX = this.getInterpolations()[0].getValue(howMuch,
                transformable.getHShear(), this.getDestinedHShear());
        double shearY = this.getInterpolations()[1].getValue(howMuch, 
                transformable.getVShear(), this.getDestinedVShear());
        transformable.setHShear(shearX);
        transformable.setVShear(shearY);
        return transformable;

    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.B25D78FA-B63C-7605-5DE7-F7760FA91ADD]
    // </editor-fold> 
    public double getDestinedVShear () {
        return this.destinedVShear;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.28C319B3-2DCC-4F72-27B0-AB7C5FCA9E98]
    // </editor-fold> 
    public double getDestinedHShear () {
        return this.destinedHShear;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.486DE7FF-D2CB-4639-ED4C-D7A4812D1CD3]
    // </editor-fold> 
    public void setDestinedVShear (double val) {
        double oldVal = this.destinedVShear;
        this.destinedVShear=val;
        propertySupport.firePropertyChange( "destinedVShear" , oldVal, val);
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.31B106EA-8959-05ED-ECEF-861BB107CE12]
    // </editor-fold> 
    public void setDestinedHShear (double val) {
        double oldVal = this.destinedHShear;
        this.destinedHShear=val;
        propertySupport.firePropertyChange( "destinedHShear" , oldVal, val);
    }

    private Interpolation[] myInterpolations=new Interpolation[2];
    private double destinedHShear=Double.NaN;
    private double destinedVShear=Double.NaN;



}

